import Mock from 'mockjs'

const users = Mock.mock({
  'list|15': [{
    base: {
      'id|+1': 1,
      name: '@cname',
      idcard: /\d{18}/,
      tel1: /\d{11}/,
      'tel2|1': [/\d{11}/, ''],
      'country|1': ['中国', ''],
      'email|1': ['@email', ''],
      'line': '',
      'wxid|1': ['', 'chengzhem', ''],
      'address|1': ['', '@county(true)'],
      'postcode|1': [/\d{6}/, ''],
      job: '',
      'photo|+1': ['@image(200x200)', ''],
      'idcardPhoto1|+1': ['@image(200x120)', ''],
      'idcardPhoto2|+1': ['@image(200x120)', ''],
      'passport|+1': ['@image(200x120)', ''],
      'bankname|1': ['', '中国民生银行'],
      'bankcard|1': ['', '6223 3434 3232 343']
    },
    buy: {
      'id|1': +1,
      subid: 1,
      'num|1': ['', '@natural(1, 990)'],
      'buy_level|1': ['@natural(0, 3)', ''],
      'credit_level|1': ['@natural(0, 3)', ''],
      'judg_level|1': ['@natural(0, 3)', ''],
      'fee_rate|1': [0.15, 0.011],
      money: '@natural(0, 20000)',
      mstate: '@natural(0, 3)', // ['未交', '可用', '提现中', '冻结']
      remark: '@csentence'
    },
    send: {
      'id|1': +1,
      subid: 1,
      'number|1': ['', '@natural(1, 990)'],
      'send_level|1': ['@natural(0, 3)', ''],
      'fee_rate|1': [0.15, 0],
      'catafee|1': ['@natural(0, 1000)', 0],
      'deal_level|1': ['@natural(0, 3)', ''],
      'deal_point|1': ['@natural(0, 100)', ''],
      remark: '@csentence'
    }
  }],
  total: 30
})



export default [
  {
    url: '/user/getUsersBySub',
    type: 'get',
    response: config => {
      return {
        code: 200,
        data: users
      }
    }
  },
  {
    url: '/user/getUsers',
    type: 'get',
    response: config => {
      return {
        code: 200,
        data: users
      }
    }
  },
  {
    url: '/user/getAllUsers',
    type: 'get',
    response: config => {
      return {
        code: 200,
        data: {
          'send|0-10': [{
            'id|+1': 1,
            name: '@cname()',
            label: '@cname()-1@natural(30000, 99999)@natural(10000, 99999)',
            'fee_rate|0.1-2': 0.011,
            'catafee|1': [0, '@natural(10000, 400000)'],
            'bankname|1': ['', '中国民生银行'],
            'bankcard|1': ['', '6223 3434 3232 343'],
            'address|1': ['', '@county(true)']
          }],
          'buy|0-10': [{
            'id|+1': 1,
            name: '@cname()',
            label: '@natural(1, 999)-@cname()-1@natural(10000, 99999)@natural(10000, 99999)',
            'fee_rate|0.1-2': 0.011,
            'bankname|1': ['', '中国民生银行'],
            'bankcard|1': ['', '6223 3434 3232 343'],
            'address|1': ['', '@county(true)']
          }]
        }
      }
    }
  },
  {
    url: '/user/getUserByField',
    type: 'get',
    response: config => {
      return {
        code: 200,
        'data|1': [users.list[0], null]
      }
    }
  },
  {
    url: '/user/OCRByIdCard',
    type: 'post',
    response: config => {
      return {
        code: 200,
        data: {
          name: '@cname',
          idcard: /\d{18}/
        }
      }
    }
  },
  {
    url: '/user/bindKey',
    type: 'post',
    response: config => {
      const { num } = config.body
      return {
        code: 200,
        data: { num },
        msg: '绑定号牌成功'
      }
    }
  },
  {
    url: '/user/updateUser',
    type: 'post',
    response: config => {
      return {
        code: 200,
        data: {},
        msg: '用户信息更新成功'
      }
    }
  },
  {
    url: '/user/setMoney',
    type: 'post',
    response: config => {
      return {
        code: 200,
        data: {},
        msg: '保证金修改成功'
      }
    }
  },
  {
    url: '/user/setVIPState',
    type: 'post',
    response: config => {
      return {
        code: 200,
        data: {},
        msg: '会员状态更新成功'
      }
    }
  },
  {
    url: '/user/setRemark',
    type: 'post',
    response: config => {
      return {
        code: 200,
        data: {},
        msg: '备注修改成功'
      }
    }
  },
  {
    url: '/user/withdraw',
    type: 'post',
    response: config => {
      const { id, remark } = config.body
      return {
        code: 200,
        data: { id:1, phone: 18812789322, buy: { num: 87,money: 0, mstate: 0}, remark, mstate: 0 },
        msg: '用户提现完成'
      }
    }
  }
]